package com.purang.web.converter;

import com.purang.web.entity.domain.UserDo;
import com.purang.web.entity.po.UserPo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * PO转换器
 *
 * @author Chunyan Li
 * @version 1.0-RELEASE
 * @since 1.0-RELEASE
 */
@Mapper
public interface PoConverter {

    PoConverter INSTANCE = Mappers.getMapper(PoConverter.class);

    @Mappings({
            @Mapping(target = "id", expression = "java(userDo.createId())"),
            @Mapping(target = "createTime", expression = "java(userDo.createTimeBigInteger(com.purang.web.entity.domain.BaseDo.FMT_SECOND_INT))"),
            @Mapping(target = "updateTime", expression = "java(userDo.createTimeBigInteger(com.purang.web.entity.domain.BaseDo.FMT_SECOND_INT))"),
            @Mapping(target = "delete", expression = "java(0)")
    })
    UserPo convert(UserDo userDo);
}
